Option Strict Off
Option Explicit On
Friend Class buscar
	Inherits System.Windows.Forms.Form
	
	Private Sub buscar_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		dtp_desde.Year = Year(Now)
		dtp_desde.Month = Month(Now)
		dtp_hasta.Year = Year(Now)
		dtp_hasta.Month = Month(Now)
		'*-*- modificar posicion controles de busqueda
		'segundo check
		With chk_registro
			.Left = VB6.TwipsToPixelsX(120)
			.Top = VB6.TwipsToPixelsY(840)
		End With
		With Image3
			.Left = VB6.TwipsToPixelsX(480)
			.Top = VB6.TwipsToPixelsY(840)
		End With
		With Label5
			.Left = VB6.TwipsToPixelsX(840)
			.Top = VB6.TwipsToPixelsY(840)
		End With
		'tercer check
		With chk_fecha
			.Left = VB6.TwipsToPixelsX(120)
			.Top = VB6.TwipsToPixelsY(1200)
		End With
		With Image2
			.Left = VB6.TwipsToPixelsX(480)
			.Top = VB6.TwipsToPixelsY(1200)
		End With
		With Label4
			.Left = VB6.TwipsToPixelsX(840)
			.Top = VB6.TwipsToPixelsY(1200)
		End With
		Me.Height = VB6.TwipsToPixelsY(2050)
		cmb_cliente.SelectedIndex = 0
	End Sub
	'UPGRADE_WARNING: Event chk_cliente.CheckStateChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub chk_cliente_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chk_cliente.CheckStateChanged
		If chk_cliente.CheckState = 1 Then
			Label1.Visible = True
			cmb_cliente.Visible = True
			cmb_cliente.SelectedIndex = 0
			txt_nombre.Visible = True
			If chk_registro.CheckState = 1 Then
				chk_registro.CheckState = System.Windows.Forms.CheckState.Unchecked
			ElseIf chk_fecha.CheckState = 1 Then 
				chk_fecha.CheckState = System.Windows.Forms.CheckState.Unchecked
			End If
			'segundo check
			With chk_registro
				.Left = VB6.TwipsToPixelsX(120)
				.Top = VB6.TwipsToPixelsY(1680)
				Image3.Left = VB6.TwipsToPixelsX(480) : Image3.Top = VB6.TwipsToPixelsY(1680)
				Label5.Left = VB6.TwipsToPixelsX(840) : Label5.Top = VB6.TwipsToPixelsY(1680)
			End With
			With chk_fecha
				.Left = VB6.TwipsToPixelsX(120)
				.Top = VB6.TwipsToPixelsY(2040)
				Image2.Left = VB6.TwipsToPixelsX(480) : Image2.Top = VB6.TwipsToPixelsY(2040)
				Label4.Left = VB6.TwipsToPixelsX(840) : Label4.Top = VB6.TwipsToPixelsY(2040)
			End With
			cmd_buscar.Left = VB6.TwipsToPixelsX(6000) : cmd_buscar.Top = VB6.TwipsToPixelsY(1200) : cmd_buscar.Visible = True
			Me.Height = VB6.TwipsToPixelsY(2850)
			
		Else
			'si los 3 son blancos
			If chk_cliente.CheckState = 0 And chk_registro.CheckState = 0 And chk_fecha.CheckState = 0 Then
				Label1.Visible = False : cmb_cliente.Visible = False : txt_nombre.Visible = False
				With chk_registro
					.Left = VB6.TwipsToPixelsX(120)
					.Top = VB6.TwipsToPixelsY(840)
					Image3.Left = VB6.TwipsToPixelsX(480) : Image3.Top = VB6.TwipsToPixelsY(840)
					Label5.Left = VB6.TwipsToPixelsX(840) : Label5.Top = VB6.TwipsToPixelsY(840)
				End With
				With chk_fecha
					.Left = VB6.TwipsToPixelsX(120)
					.Top = VB6.TwipsToPixelsY(1200)
					Image2.Left = VB6.TwipsToPixelsX(480) : Image2.Top = VB6.TwipsToPixelsY(1200)
					Label4.Left = VB6.TwipsToPixelsX(840) : Label4.Top = VB6.TwipsToPixelsY(1200)
				End With
				cmd_buscar.Visible = False
				Me.Height = VB6.TwipsToPixelsY(2050)
				
			Else '/*/*/*/- BLANCO Y SELECCIONA OTRO
				If chk_cliente.CheckState = 0 Then
					Label1.Visible = False : cmb_cliente.Visible = False : txt_nombre.Visible = False
					cmb_cliente.Text = "" : txt_nombre.Text = "" : cmd_buscar.Visible = False
				End If
				chk_registro.Left = VB6.TwipsToPixelsX(120) : chk_registro.Top = VB6.TwipsToPixelsY(840)
				Image3.Left = VB6.TwipsToPixelsX(480) : Image3.Top = VB6.TwipsToPixelsY(840) : Label5.Left = VB6.TwipsToPixelsX(840) : Label5.Top = VB6.TwipsToPixelsY(840)
				
			End If
			'si es blanco
			
		End If
		
	End Sub
	'UPGRADE_WARNING: Event chk_registro.CheckStateChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub chk_registro_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chk_registro.CheckStateChanged
		Select Case chk_registro.CheckState
			Case Is = 1 'activo
				'si los dos anteriores estan en blanco
				If chk_cliente.CheckState = 1 Then
					chk_cliente.CheckState = System.Windows.Forms.CheckState.Unchecked
				ElseIf chk_fecha.CheckState = 1 Then 
					chk_fecha.CheckState = System.Windows.Forms.CheckState.Unchecked
				End If
				With chk_registro
					.Left = VB6.TwipsToPixelsX(120)
					.Top = VB6.TwipsToPixelsY(840)
					Image3.Left = VB6.TwipsToPixelsX(480) : Image3.Top = VB6.TwipsToPixelsY(840)
					Label5.Left = VB6.TwipsToPixelsX(840) : Label5.Top = VB6.TwipsToPixelsY(840)
					txt_reg.Left = VB6.TwipsToPixelsX(600) : txt_reg.Top = VB6.TwipsToPixelsY(1200) : txt_reg.Visible = True : txt_reg.Text = ""
					cmd_buscar.Left = VB6.TwipsToPixelsX(6000) : cmd_buscar.Top = VB6.TwipsToPixelsY(1200) : cmd_buscar.Visible = True
				End With
				With chk_fecha
					.Left = VB6.TwipsToPixelsX(120)
					.Top = VB6.TwipsToPixelsY(1650)
					Image2.Left = VB6.TwipsToPixelsX(480) : Image2.Top = VB6.TwipsToPixelsY(1650)
					Label4.Left = VB6.TwipsToPixelsX(840) : Label4.Top = VB6.TwipsToPixelsY(1650)
				End With
				Me.Height = VB6.TwipsToPixelsY(2550) '2950
			Case Is = 0 'inactivo
				If chk_cliente.CheckState = 0 And chk_fecha.CheckState = 0 Then
					With chk_fecha
						.Left = VB6.TwipsToPixelsX(120)
						.Top = VB6.TwipsToPixelsY(1200)
						Image2.Left = VB6.TwipsToPixelsX(480) : Image2.Top = VB6.TwipsToPixelsY(1200)
						Label4.Left = VB6.TwipsToPixelsX(840) : Label4.Top = VB6.TwipsToPixelsY(1200)
					End With
					txt_reg.Visible = False : txt_reg.Text = ""
					cmd_buscar.Visible = False
					Me.Height = VB6.TwipsToPixelsY(2050)
				Else
					
					With chk_registro
						.Left = VB6.TwipsToPixelsX(120)
						.Top = VB6.TwipsToPixelsY(840)
						Image3.Left = VB6.TwipsToPixelsX(480) : Image3.Top = VB6.TwipsToPixelsY(840)
						Label5.Left = VB6.TwipsToPixelsX(840) : Label5.Top = VB6.TwipsToPixelsY(840)
						txt_reg.Visible = False : txt_reg.Text = ""
						cmd_buscar.Visible = False
					End With
				End If
				
		End Select
	End Sub
	'UPGRADE_WARNING: Event chk_fecha.CheckStateChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub chk_fecha_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chk_fecha.CheckStateChanged
		Select Case chk_fecha.CheckState
			Case Is = 1 'activo
				If chk_cliente.CheckState = 1 Then
					chk_cliente.CheckState = System.Windows.Forms.CheckState.Unchecked
				ElseIf chk_registro.CheckState = 1 Then 
					chk_registro.Left = VB6.TwipsToPixelsX(120) : chk_registro.Top = VB6.TwipsToPixelsY(840)
					Image3.Left = VB6.TwipsToPixelsX(480) : Image3.Top = VB6.TwipsToPixelsY(840) : Label5.Left = VB6.TwipsToPixelsX(840) : Label5.Top = VB6.TwipsToPixelsY(840)
					chk_registro.CheckState = System.Windows.Forms.CheckState.Unchecked
				End If
				With chk_fecha
					.Left = VB6.TwipsToPixelsX(120)
					.Top = VB6.TwipsToPixelsY(1200)
					Image2.Left = VB6.TwipsToPixelsX(480) : Image2.Top = VB6.TwipsToPixelsY(1200)
					Label4.Left = VB6.TwipsToPixelsX(840) : Label4.Top = VB6.TwipsToPixelsY(1200)
				End With
				Label6.Left = VB6.TwipsToPixelsX(600) : Label6.Top = VB6.TwipsToPixelsY(1600) : Label6.Visible = True
				dtp_desde.Left = VB6.TwipsToPixelsX(1320) : dtp_desde.Top = VB6.TwipsToPixelsY(1600) : dtp_desde.Visible = True
				dtp_hasta.Left = VB6.TwipsToPixelsX(3600) : dtp_hasta.Top = VB6.TwipsToPixelsY(1600) : dtp_hasta.Visible = True
				Label2.Left = VB6.TwipsToPixelsX(2880) : Label2.Top = VB6.TwipsToPixelsY(1600) : Label2.Visible = True
				cmd_buscar.Visible = True : cmd_buscar.Left = VB6.TwipsToPixelsX(6000) : cmd_buscar.Top = VB6.TwipsToPixelsY(1600)
				Me.Height = VB6.TwipsToPixelsY(2550)
			Case Is = 0 'inactivo
				
				If chk_cliente.CheckState = 0 And chk_registro.CheckState = 0 Then
					Label6.Visible = False : dtp_desde.Visible = False
					dtp_hasta.Visible = False : Label2.Visible = False
					cmd_buscar.Visible = False : Me.Height = VB6.TwipsToPixelsY(2050)
				Else
					Label6.Visible = False : dtp_desde.Visible = False
					dtp_hasta.Visible = False : Label2.Visible = False
					cmd_buscar.Visible = False
				End If
				
				
		End Select
	End Sub
	Private Sub cmd_buscar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmd_buscar.Click
		Dim cod As String
		Dim band As Short
		
		If chk_cliente.CheckState = 1 Then
			If txt_nombre.Text <> "" Then
				Select Case cmb_cliente.SelectedIndex
					Case Is = 0 'empresa
						'UPGRADE_WARNING: Couldn't resolve default property of object devolverCod(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						cod = devolverCod(" DISTINCT cod_empresa as cod", "empresa", "nombre='" & txt_nombre.Text & "'", 0)
						band = 1
					Case Is = 1 'cliente
						'UPGRADE_WARNING: Couldn't resolve default property of object devolverCod(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						cod = devolverCod(" DISTINCT codigo as cod", "datos_persona", "apellido_pat='" & txt_nombre.Text & "'", 0)
						band = 2
				End Select
			Else
				Call mensajes(7)
			End If
			
			'UPGRADE_WARNING: Couldn't resolve default property of object devolverBusqueda(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			cadParametros = devolverBusqueda(cod, band)
			If cadParametros = "0" Then
				Call mensajes(7)
			Else
				Me.Close() : listabuscar.Show()
			End If
			'cadParametros = band & "+" & cod:  Unload Me: If bandReporte <> 1 Then listabuscar.Show
			
		ElseIf chk_registro.CheckState = 1 Then  'registro
			If txt_reg.Text <> "" Then
				'cod = devolverCod(" DISTINCT cod_protocolo as cod", "protocolo", "nro_reg='" & txt_reg.Text & "'", 0)
				'UPGRADE_WARNING: Couldn't resolve default property of object devolverBusqueda(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				cadParametros = devolverBusqueda((txt_reg.Text), 4)
				If cadParametros = "0" Then
					Call mensajes(7)
				Else
					Me.Close() : tickel1.Show()
				End If
			End If
		ElseIf chk_fecha.CheckState = 1 Then  'fechaas
			
			cod = dtp_desde.Year & "-" & dtp_desde.Month & "-" & dtp_desde.Day & "*" & dtp_hasta.Year & "-" & dtp_hasta.Month & "-" & dtp_hasta.Day
			'UPGRADE_WARNING: Couldn't resolve default property of object devolverBusqueda(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			cadParametros = devolverBusqueda(cod, 3)
			If cadParametros = "0" Then
				Call mensajes(7)
			Else
				Me.Close() : listabuscar.Show()
			End If
			'band = 3
			''cadParametros = 3 & "," & cod: Unload Me: If bandReporte <> 1 Then listabuscar.Show
		End If
		
	End Sub
End Class